home *** CD-ROM | disk | FTP | other *** search
- Path: newsxfer2.itd.umich.edu!agate!kaskel
- From: kaskel@durban.berkeley.edu (Bruce Kaskel)
- Newsgroups: comp.lang.pascal.misc,comp.lang.c++,comp.lang.c,comp.lang.pascal.borland
- Subject: Re: Tough FACTORIAL math problem...
- Date: 22 Feb 1996 07:01:46 GMT
- Organization: U.C. Berkeley Math. Department.
- Message-ID: <4gh4cq$8eo@agate.berkeley.edu>
- References: <4fr8be$ass@news.iconn.net> <4g2n5u$kqj@sun001.spd.dsccc.com> <danpop.824595562@rscernix> <4gaucn$cdu@beyond.escape.com>
- NNTP-Posting-Host: durban.berkeley.edu
-
- In article <4gaucn$cdu@beyond.escape.com>,
- Ken Nahshon <viking@escape.com> wrote:
- >Who origianlly asked about this problem...?
- >This person is obviousely a serious loser because this was one of the
- >qualifying round problems for the United States of America Computing
- >Olypiad(USACO). The problem is EXTREMELY simple. All that must be done
- >is remove all the trailing zeros after each iteration and (the way I did
- >it) minus 10000 from the total if the total is greater than 10000.
- >Another, cleaner solution is to use the modulus operator.
- >
- >ps I did this, and speak from expierience. MINE WORKS! :)
-
-
- So after you have finished the n-th iteration, you have multiplied your
- number by n, removed the trailing zeros, and subtracted 10000 until the
- number is not greater than 10000. Are you claiming that you end up with
- a number with the same last digit as n! ?
-
- Strictly speaking this is not correct.
-
- Take the 3125-th iteration. Your algorithm yields 995.
- But the rightmost non-zero digit of 3125! is not 5.
-
- --Bruce Kaskel
-
-
-